Skip to content

Conversation

@kkent030315
Copy link
Contributor

@kkent030315 kkent030315 commented Jul 27, 2025

These flags were treated as explicit errors, which could cause compatibility issues with MS link.exe. To address this, LLD was updated to ignore them, aligning its behavior with MS link.exe. The latter two options affect how MS link.exe generates metadata for its PGO. LLD doesn't generate any such metadata right now (and doesn't work with the MSVC PGO feature), so those options are kept as no-ops.

  • Added /emittoolversioninfo[:no] flag in LLD/COFF options
    • This flag emits a rich header between DOS stub and PE header. LLVM does not emit the rich header at all.
  • Added /novcfeature flag in LLD/COFF options
  • Added /nocoffgrpinfo flag in LLD/COFF options

@llvmbot
Copy link
Member

llvmbot commented Jul 27, 2025

@llvm/pr-subscribers-lld-coff

Author: None (kkent030315)

Changes

Added LLD flags to be ignored to align with MS link.exe.

  • Added /emittoolversioninfo[:no] flag in LLD/COFF options
  • Added /novcfeature flag in LLD/COFF options
  • Added /nocoffgrpinfo flag in LLD/COFF options

Since LLVM does not implement POGO (Profile-guided Optimization, also known as "PGO"), this is completely ignorable without being problematic. Some of the flags are well described in this blog.

Example of the error

LLD(lld-link.exe): 19.1.5

1>lld-link : error : could not open '/EMITTOOLVERSIONINFO:NO': no such file or directory
1>lld-link : error : could not open '/NOVCFEATURE': no such file or directory
1>lld-link : error : could not open '/NOCOFFGRPINFO': no such file or directory

Full diff: https://github.com/llvm/llvm-project/pull/150815.diff

1 Files Affected:

  • (modified) lld/COFF/Options.td (+12)
diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td
index 2a82fb5cd8845..bde1f5f950b4b 100644
--- a/lld/COFF/Options.td
+++ b/lld/COFF/Options.td
@@ -353,6 +353,18 @@ def fastfail : F<"fastfail">;
 def kernel : F<"kernel">;
 def pdbcompress : F<"pdbcompress">;
 def emitpogophaseinfo : F<"emitpogophaseinfo">;
+def emittoolversioninfo: B<
+    "emittoolversioninfo",
+    "Emit a tool version info after DOS header (so-called Rich header, default)",
+    "Do not emit a tool version info after DOS header (so-scalled Ricb header)">;
+def novcfeature: B<
+    "novcfeature",
+    "Embeds tool version info in debug directory (default)",
+    "Do not embed tool version info in debug directory">;
+def nocoffgrpinfo: B<
+    "nocoffgrpinfo",
+    "Embeds COFFGRP info in debug directory (default)",
+    "Do not dmbeds COFFGRP info in debug directory">;
 def noexp : F<"noexp">;
 
 def delay : P_priv<"delay">;

@llvmbot
Copy link
Member

llvmbot commented Jul 27, 2025

@llvm/pr-subscribers-platform-windows

Author: None (kkent030315)

Changes

Added LLD flags to be ignored to align with MS link.exe.

  • Added /emittoolversioninfo[:no] flag in LLD/COFF options
  • Added /novcfeature flag in LLD/COFF options
  • Added /nocoffgrpinfo flag in LLD/COFF options

Since LLVM does not implement POGO (Profile-guided Optimization, also known as "PGO"), this is completely ignorable without being problematic. Some of the flags are well described in this blog.

Example of the error

LLD(lld-link.exe): 19.1.5

1&gt;lld-link : error : could not open '/EMITTOOLVERSIONINFO:NO': no such file or directory
1&gt;lld-link : error : could not open '/NOVCFEATURE': no such file or directory
1&gt;lld-link : error : could not open '/NOCOFFGRPINFO': no such file or directory

Full diff: https://github.com/llvm/llvm-project/pull/150815.diff

1 Files Affected:

  • (modified) lld/COFF/Options.td (+12)
diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td
index 2a82fb5cd8845..bde1f5f950b4b 100644
--- a/lld/COFF/Options.td
+++ b/lld/COFF/Options.td
@@ -353,6 +353,18 @@ def fastfail : F<"fastfail">;
 def kernel : F<"kernel">;
 def pdbcompress : F<"pdbcompress">;
 def emitpogophaseinfo : F<"emitpogophaseinfo">;
+def emittoolversioninfo: B<
+    "emittoolversioninfo",
+    "Emit a tool version info after DOS header (so-called Rich header, default)",
+    "Do not emit a tool version info after DOS header (so-scalled Ricb header)">;
+def novcfeature: B<
+    "novcfeature",
+    "Embeds tool version info in debug directory (default)",
+    "Do not embed tool version info in debug directory">;
+def nocoffgrpinfo: B<
+    "nocoffgrpinfo",
+    "Embeds COFFGRP info in debug directory (default)",
+    "Do not dmbeds COFFGRP info in debug directory">;
 def noexp : F<"noexp">;
 
 def delay : P_priv<"delay">;

@llvmbot
Copy link
Member

llvmbot commented Jul 27, 2025

@llvm/pr-subscribers-lld

Author: None (kkent030315)

Changes

Added LLD flags to be ignored to align with MS link.exe.

  • Added /emittoolversioninfo[:no] flag in LLD/COFF options
  • Added /novcfeature flag in LLD/COFF options
  • Added /nocoffgrpinfo flag in LLD/COFF options

Since LLVM does not implement POGO (Profile-guided Optimization, also known as "PGO"), this is completely ignorable without being problematic. Some of the flags are well described in this blog.

Example of the error

LLD(lld-link.exe): 19.1.5

1&gt;lld-link : error : could not open '/EMITTOOLVERSIONINFO:NO': no such file or directory
1&gt;lld-link : error : could not open '/NOVCFEATURE': no such file or directory
1&gt;lld-link : error : could not open '/NOCOFFGRPINFO': no such file or directory

Full diff: https://github.com/llvm/llvm-project/pull/150815.diff

1 Files Affected:

  • (modified) lld/COFF/Options.td (+12)
diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td
index 2a82fb5cd8845..bde1f5f950b4b 100644
--- a/lld/COFF/Options.td
+++ b/lld/COFF/Options.td
@@ -353,6 +353,18 @@ def fastfail : F<"fastfail">;
 def kernel : F<"kernel">;
 def pdbcompress : F<"pdbcompress">;
 def emitpogophaseinfo : F<"emitpogophaseinfo">;
+def emittoolversioninfo: B<
+    "emittoolversioninfo",
+    "Emit a tool version info after DOS header (so-called Rich header, default)",
+    "Do not emit a tool version info after DOS header (so-scalled Ricb header)">;
+def novcfeature: B<
+    "novcfeature",
+    "Embeds tool version info in debug directory (default)",
+    "Do not embed tool version info in debug directory">;
+def nocoffgrpinfo: B<
+    "nocoffgrpinfo",
+    "Embeds COFFGRP info in debug directory (default)",
+    "Do not dmbeds COFFGRP info in debug directory">;
 def noexp : F<"noexp">;
 
 def delay : P_priv<"delay">;

@mstorsjo
Copy link
Member

Since LLVM does not implement POGO (Profile-guided Optimization, also known as "PGO")

This seems mildly incorrect - LLVM/Clang does support PGO just fine, but it doesn't support the MSVC intermediate files or produce the exact same metadata in the output as MSVC does.

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks fine, but the commit message (the PR description) may need a little bit of rewording.

@kkent030315
Copy link
Contributor Author

@mstorsjo Thanks for the review. I updated the PR title, does it look like good for you or should I fix something? Let me know :)

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mstorsjo
Copy link
Member

I updated the PR title, does it look like good for you or should I fix something?

Thanks! Although it could be good to clarify that those options affect metadata generation for the MSVC style PGO, and LLD doesn't do that. As it stands right now it is very unclear what these options have to do with the statement about PGO support, as the option names don't make that clear at all.

So perhaps instead of this:

LLVM supports PGO (Profile-Guided Optimization) but does not yet have the capability to emit MS-compatible metadata.

We'd have this:

The latter two options affect how MS link.exe generates metadata for its PGO. LLD doesn't generate any such metadata right now (and doesn't work with the MSVC PGO feature), so those options are kept as no-ops.

Then also on another hand; the latter two options are undocumented, right? So there's quite little risk of them being used much in the wild at all (contrary to the first one which is totally understandable to handle).

@kkent030315
Copy link
Contributor Author

We'd have this:

The latter two options affect how MS link.exe generates metadata for its PGO. LLD doesn't generate any such metadata right now (and doesn't work with the MSVC PGO feature), so those options are kept as no-ops.

Updated. Thanks for the better one!

Then also on another hand; the latter two options are undocumented, right? So there's quite little risk of them being used much in the wild at all (contrary to the first one which is totally understandable to handle).

Well, there are many projects uses those flags (e.g., UEFI binaries) and I experienced the odd. For example, if I had this cmake setup, it is no way compatible with MSVC toolchain (link.exe) and Clang toolchain (lld-link.exe). This is solvable by putting if statement to those options but that makes the cmake config redundant. It'd be better we just ignore those :)

target_link_options(foo PRIVATE
    # Decrease the binary size
    /EMITTOOLVERSIONINFO:NO
    /EMITPOGOPHASEINFO
    /NOVCFEATURE
    /NOCOFFGRPINFO
)

@mstorsjo
Copy link
Member

We'd have this:

The latter two options affect how MS link.exe generates metadata for its PGO. LLD doesn't generate any such metadata right now (and doesn't work with the MSVC PGO feature), so those options are kept as no-ops.

Updated. Thanks for the better one!

Then also on another hand; the latter two options are undocumented, right? So there's quite little risk of them being used much in the wild at all (contrary to the first one which is totally understandable to handle).

Well, there are many projects uses those flags (e.g., UEFI binaries) and I experienced the odd. For example, if I had this cmake setup, it is no way compatible with MSVC toolchain (link.exe) and Clang toolchain (lld-link.exe). This is solvable by putting if statement to those options but that makes the cmake config redundant. It'd be better we just ignore those :)

target_link_options(foo PRIVATE
    # Decrease the binary size
    /EMITTOOLVERSIONINFO:NO
    /EMITPOGOPHASEINFO
    /NOVCFEATURE
    /NOCOFFGRPINFO
)

Ok, fair enough. Thanks! Then I think this one looks good.

@mstorsjo mstorsjo merged commit 3e42146 into llvm:main Jul 29, 2025
9 checks passed
@kkent030315 kkent030315 deleted the lldignoreflags branch July 29, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants